package com.guigu.tms.aggregation.service.impl;

import com.guigu.tms.aggregation.mapper.DriverJobMapper;
import com.guigu.tms.aggregation.mapper.TaskTransportMapper;
import com.guigu.tms.commons.aggregation.entity.DriverJob;
import com.guigu.tms.commons.aggregation.entity.TaskTransport;
import com.guigu.tms.commons.aggregation.entity.TruckDriver;
import com.guigu.tms.aggregation.mapper.TruckDriverMapper;
import com.guigu.tms.aggregation.service.ITruckDriverService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 司机表 服务实现类
 * </p>
 *
 * @author wj
 * @since 2022-10-21
 */
@Service
public class TruckDriverServiceImpl extends ServiceImpl<TruckDriverMapper, TruckDriver> implements ITruckDriverService {

    @Autowired
    TruckDriverMapper truckDriverMapper;

    @Autowired
    DriverJobMapper driverJobMapper;

    @Autowired
    TaskTransportMapper taskTransportMapper;

    @Override
    public List<DriverJob> ShowDriverJob(Map<String,String> map) {
        return driverJobMapper.ShowDriverJob(map);
    }

    @Override
    public int UploadJf(String jobId,String taskId,String deliverPicture,String transportCertificate) {
        DriverJob driverJob=new DriverJob();
        driverJob.setId(jobId);
        driverJob.setStatus(4);
        driverJobMapper.updateById(driverJob);
        TaskTransport taskTransport=new TaskTransport();
        taskTransport.setId(taskId);
        taskTransport.setStatus(4);
        taskTransport.setDeliverPicture(deliverPicture);
        taskTransport.setTransportCertificate(transportCertificate);
        int updateById = taskTransportMapper.updateById(taskTransport);
        return updateById;
    }

    @Override
    public int UploadTh(String jobId, String taskId, String cargoPickUpPicture) {
        DriverJob driverJob=new DriverJob();
        driverJob.setId(jobId);
        driverJob.setStatus(2);
        driverJobMapper.updateById(driverJob);
        TaskTransport taskTransport=new TaskTransport();
        taskTransport.setId(taskId);
        taskTransport.setStatus(2);
        taskTransport.setCargoPickUpPicture(cargoPickUpPicture);
        int updateById = taskTransportMapper.updateById(taskTransport);
        return updateById;
    }
}
